<template>
  <div class="rechargeList">
    <!-- 面包屑导航 -->
    <div class="center-w">
      <!-- <div class="head">
        <div class="title">充值列表</div>
      </div> -->
      <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="充值记录" name="1">
          <span slot="label"><i class="el-icon-bank-card"></i> 充值记录</span>
        </el-tab-pane>
        <el-tab-pane label="余额记录" name="2">
          <span slot="label"><i class="el-icon-coin"></i> 余额记录</span>
        </el-tab-pane>
      </el-tabs>
      <el-table size="small" :data="tableData">
        <el-table-column type="index" align="center" width="50">
        </el-table-column>
        <el-table-column prop="user" align="center" width="300" label="头像">
          <template slot-scope="scope">
            <el-image :src="scope.row.wxImg" fit="cover" :lazy="true">
              <div slot="error" class="image-slot">
                <!-- <i class="el-icon-picture-outline"></i> src="https://img1.baidu.com/it/u=4035421571,4160111639&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500" -->
                <el-image
                  class="head-img"
                  src="https://img2.baidu.com/it/u=3969906574,3231239394&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500"
                >
                </el-image>
              </div>
            </el-image>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="wxName"
          label="用户名"
        >
      <template slot-scope="scope">
     <span>{{ scope.row.wxName || '/' }}</span>
      </template>
      </el-table-column>
        <el-table-column
          v-if="activeName == 2"
          align="center"
          prop="orderNo"
          label="订单编号"
        >
        </el-table-column>
        <el-table-column
          v-if="activeName == 1"
          align="center"
          prop="amount"
          label="充值金额"
        >
        </el-table-column>
        <el-table-column
          v-if="activeName == 1"
          align="center"
          prop="giftAmount"
          label="赠送金额"
        >
        </el-table-column>
        <el-table-column
          align="center"
          prop="totalAmount"
          :label="activeName == 1 ? '总金额' : '消费金额'"
        >
          <template slot-scope="scope">
            <span style="color: red;">{{ scope.row.totalAmount }}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="createTime"
          :label="activeName == 1 ? '充值时间' : '消费时间'"
        >
        </el-table-column>
      </el-table>
      <!-- 分页组件 -->
      <Pagination
        v-bind:child-msg="pageparm"
        @callFather="callFather"
      ></Pagination>
    </div>
  </div>
</template>

<script>
import Pagination from "../../components/Pagination";

import { rechargeList } from "../../api/recharge";

export default {
  name: "rechargeList",
  data() {
    return {
      // 目前没有做列表处理 后续需要多功能控制在进行优化处理
      tableData: [],
      activeName: "1",
      pageparm: {
        pageIndex: 1,
        pageSize: 10,
        total: 0,
        type: 0
      }
    };
  },
  components: {
    Pagination
  },

  created() {
    this.getRechargeList();
  },
  methods: {
    handleClick(tab) {
      this.pageparm.type = tab.name == "1" ? 0 : 1;
      this.pageparm.pageIndex = 1;
      this.getRechargeList();
    },
    // 分页插件事件
    callFather(parm) {
      this.pageparm.pageIndex = parm.pageIndex;
      this.pageparm.pageSize = parm.size;
      this.getRechargeList();
    },

    async getRechargeList() {
      let res = await rechargeList(this.pageparm);
      if (res.code == 200) {
        this.tableData = res.data ? res.data.items : [];
        this.pageparm.total = res.data.totalCount;
      } else {
        this.$message.error(res.error);
      }
    }
  }
};
</script>

<style lang="less" scoped>
.center-w {
  display: flex;
  /* align-items: center; */
  flex-direction: column;
  background-color: #fff;
  height: 85vh;
  padding: 20px;
  border: 1px solid #ccc;
  margin: 20px;
  .title {
    color: rgba(16, 16, 16, 1);
    font-size: 20px;
    margin-bottom: 10px;
  }
  /deep/ .el-tabs__item {
    height: 60px !important;
    width: 140px;
    line-height: 60px;
    font-size: 16px;
    font-weight: 700;
  }
  .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .el-image {
    width: 35px;
    height: 35px;
    // border-radius: 50%;
  }
  .btn-w {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    .btn {
      width: 80px;
      height: 40px;
      border: 1px solid #ccc;
      line-height: 40px;
      text-align: center;
    }
  }
}
</style>
